clear all
set more off

local out2="\outregsQJE\"
cd "\workfiles"

use step001_QJE_2, clear

tsset firm_id time

*** define treatment as given inflation TIMES treatment status
gen Treat=treatment_old*infl

*** restrict the sample only to the period with treatment and control groups
keep if time>=208

***======================================================
*** 			responses by sector
***======================================================

*** manufacturing 
ivreghdfe it12_all Treat [aw=peso] if setton3==1, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", replace dta dec(3) ctitle("MNFG")

*** services 
ivreghdfe it12_all Treat [aw=peso] if setton3==2, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("SERV")

*** construction 
ivreghdfe it12_all Treat [aw=peso] if setton3==3, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("CONS")

***======================================================
*** 			responses by firm size
***======================================================

xtile size0=add, nq(3)
tabstat add, by(size0) stat(N min mean max) 

*** less than 100 employees 
ivreghdfe it12_all Treat [aw=peso] if add<=99, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("size: 50-99")

*** 100-299 employees 
ivreghdfe it12_all Treat [aw=peso] if add>99 & add<=299, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("size: 100-299")

*** 300 or more employees 
ivreghdfe it12_all Treat [aw=peso] if add>=300 & add~=., ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("size: 300+")


***======================================================
*** 			responses by export share
***======================================================

*** 0% export
ivreghdfe it12_all Treat [aw=peso] if export==1, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("export: 0%")

*** 1% to 33% export
ivreghdfe it12_all Treat [aw=peso] if export==2, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("export: 1-33%")

*** 34%+ 
ivreghdfe it12_all Treat [aw=peso] if (export==3 | export==4) & export~=., ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("export: 34%+")

***======================================================
*** 			responses by geography
***======================================================

*** 0% export
ivreghdfe it12_all Treat [aw=peso] if (area==1 | area==2), ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("North")

*** 1% to 33% export
ivreghdfe it12_all Treat [aw=peso] if area==3, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("Center")

*** 34%+ 
ivreghdfe it12_all Treat [aw=peso] if area==4, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Appendix_Table03.dta", append dta dec(3) ctitle("South")

